home *** CD-ROM | disk | FTP | other *** search
- {TURBO Pascal:
-
- Window BIOS demonstration. Written 1984 by J. Eric Roskos.
-
- This program demonstrates the Window BIOS, illustrating the recommended
- methods of creating and deleting windows. The following are the Window
- BIOS functions; they are extensions to the ROM BIOS's INT 10H functions.
-
- AH=$41 Create Window. (CH,CL) contains the (row,column) of the upper
- left corner of the window, and (DH,DL) contains the (row,column)
- of the lower right corner. AX returns 0 if the window was
- created, or 1 if there was no space in the BIOS tables to do so.
-
- AH=$42 Delete Window. The top (most recently created) window is de-
- leted. Note that this uses the simple model of
- overlayed sheets of paper on a desktop; the most recent window
- is thus always the top sheet of paper on the desk. This call
- has no parameters. AX returns 0 if the window was deleted, or
- 1 if there was no window to delete.
-
- AH=$43 Create Frame. A frame is drawn around the outermost rows and
- columns of the current window. Several nested frames may be
- drawn, if any use for this exists. This call presently has no
- parameters, but AL must be 0. No status is returned via AX.
-
- AH=$40 Change Window Dimensions. This call should be used with
- caution, as explained below. The parameters to this call are
- the same as for function $41. The current window's dimensions
- are changed to the specified values. The new values should
- place the new boundaries of the window inside the window most
- recently created with call $41. The purpose of this function is
- to put non-scrolling information around the outside boundary
- of the window, such as the "title bar" in Lisa/McIntosh
- windows which appears at the top of some windows. If this
- function is used to change the dimensions, it must be used
- again to set the window dimensions back to those originally
- specified by function $41 before executing the Delete Window
- function, or garbage will appear on the screen when the window
- is deleted. No status is returned via AX.
- }
-
- program windowdemo;
- type
- recpack = record
- ax,bx,cx,dx,bp,si,di,ds,es,flag: integer;
- end;
-
- var
- param: recpack;
- reply: string[80];
-
- {
- newwindow(l,t,r,b): create a new window. The upper left corner is
- at coordinates (l,t) and the bottom right corner is at coordinates
- (r,b). (l=left, t=top, r=right, b=bottom). The coordinates have
- origin (0,0) at the upper left corner of the screen. Returns true if
- the window could be created, or false if it couldn't (because there
- wasn't any space left in the window stack).
- }
-
- function newwindow(l,t,r,b: integer):boolean;
- begin
- param.ax := $4100; { function $41 = create window }
- param.cx := t*$100 + l;
- param.dx := b*$100 + r;
- intr($10,param);
- newwindow := param.ax = 0;
- param.ax := $4300; { function $43 = draw frame }
- intr($10,param);
- ClrScr; { screen MUST be cleared after creating window }
- end;
-
- {
- delwindow: delete the top window. Returns true if the window was
- deleted, or false if there was no window. WARNING: if you use function
- $40 to change the dimensions of the window, you MUST change them back
- to their original value before deleting the window.
- }
-
- function delwindow:boolean;
- begin
- param.ax := $4200;
- param.ds := Dseg;
- intr($10,param);
- delwindow := param.ax = 0;
- end;
-
- {
- xwindow: exit from all windows. Calls delwindow repeatedly until all
- the windows have been deleted. It is a good idea to do this before
- exiting from the program; although DOS will use whatever window you
- create, some programs, such as the Turbo Pascal editor and Edix, will
- not work right in smaller windows.
- }
-
- procedure xwindow;
- begin
- repeat until not delwindow;
- end;
-
-
- begin
- if not newwindow(5,5,50,17) then writeln('New window failed.');
- writeln('Hello, I am in a window.');
- delay(1000);
- writeln('As soon as I fill this one up just a little bit here to make sure everything');
- delay(1000);
- writeln('is fine, I will switch');
- delay(1000);
- writeln('to another window.');
- delay(1000);
- if not newwindow(10,3,20,8) then writeln('New window failed.');
- delay(1000);
- writeln('There now, is');
- delay(1000);
- writeln('this narrow');
- delay(1000);
- writeln('enough for you,');
- delay(1000);
- writeln('or not? lets');
- delay(1000);
- writeln('have some scr-');
- delay(1000);
- writeln('olling here.');
- delay(1000);
- writeln('That was a');
- delay(1000);
- writeln('hyphenated word,');
- delay(1000);
- writeln('not an error');
- delay(1000);
- write('[cr]:');
- readln(reply);
- if not delwindow then writeln('window deletion failed');
- write('Now we''re back here! Push [cr] again.');
- readln(reply);
- if not delwindow then writeln('window deletion failed');
- writeln('Now everything should be back to normal.');
- xwindow;
- end.
-